<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:dssp="http://schemas.microsoft.com/xw/2004/10/dssp.html"
   xmlns:s="http://www.w3.org/2003/05/soap-envelope"
   xmlns:drive="http://schemas.vexrobotics.com/robotics/2011/09/vexservice.drive.html"
   xmlns:motor="http://schemas.microsoft.com/robotics/2006/05/motor.html"
      >

  <xsl:import href="/resources/dss/Microsoft.Dss.Runtime.Home.MasterPage.xslt" />

  <xsl:template match="/">
    <xsl:comment>
      <!-- Service Header Info -->
    </xsl:comment>
    <xsl:variable name="title">
      VEX Drive
    </xsl:variable>
    <xsl:variable name="serviceName">
      VEX Drive
    </xsl:variable>
    <xsl:variable name="description">
      Controls the VEX motor configuration as a two-wheel differential drive.
    </xsl:variable>

    <xsl:call-template name="MasterPage">
      <xsl:with-param name="serviceName" select="$serviceName" />
      <xsl:with-param name="description" select="$description" />
      <!-- If title is not provided, serviceName will be used instead. -->
      <xsl:with-param name="title">
        <xsl:value-of select="$serviceName" />
        <xsl:if test="$title != ''">
          <xsl:text> - </xsl:text>
          <xsl:value-of select="$title" />
        </xsl:if>
      </xsl:with-param>
      <!-- Possible values for navigation are: 'Open', 'Closed', and 'None'
           'Open' is the default value. -->
      <xsl:with-param name="navigation" select="'Open'" />
      <!-- The contents of head param will be placed just before the </head> tag in html. -->
      <xsl:with-param name="head">
        <style type="text/css">
          /* Service-specific stylesheet goes here */
        </style>
        <script language="javascript" type="text/javascript">
          <![CDATA[<!--

/* Service-specific script goes here */

dssRuntime.init = function()
{
  // Add page initialization code here.
  // This function is attached to the window.onload event.
  // Do not override window.onload.
}

//-->     ]]>
        </script>
      </xsl:with-param>
    </xsl:call-template>
  </xsl:template>

  
  <xsl:template match="drive:VEXDriveState">
    <form method="POST" action="" name="CustomPower">
      <table width="100%">
        <tr>
          <th colspan="2">VEX Differential Drive</th>
        </tr>
        <tr>
          <tr>
            <th>Drive Name:</th>
            <td>
              <input type="text" name="Name" size="80">
                <xsl:attribute name="value">
                  <xsl:value-of select="drive:Name"/>
                </xsl:attribute>
              </input>
            </td>
          </tr>
          <td width="50%">
            <table width="100%">
              <tr>
                <th>Identifier:</th>
                <td>
                  <xsl:value-of select="drive:LeftWheel/drive:MotorPort"/>
                </td>
              </tr>
              <tr>
                <th>Radius:</th>
                <td>
                  <xsl:value-of select="drive:LeftWheel/drive:WheelRadius"/>
                </td>
              </tr>
              <tr>
                <th>Gear Ratio:</th>
                <td>
                  <xsl:value-of select="drive:LeftWheel/drive:GearRatio"/>
                </td>
              </tr>
              <tr>
                <th>Current Power:</th>
                <td>
                  <input type="text" name="LeftPower" size="20">
                    <xsl:attribute name="value">
                      <xsl:value-of select="drive:LeftWheelPower"/>
                    </xsl:attribute>
                  </input>
                </td>
              </tr>
              <tr>
                <th>Reverse Polarity:</th>
                <td>
                  <xsl:value-of select="drive:LeftWheel/drive:ReversePolarity"/>
                </td>
              </tr>
            </table>
          </td>
          <td width="50%">
            <table width="100%">
              <tr>
              </tr>
              <tr>
                <th>Identifier:</th>
                <td>
                  <xsl:value-of select="drive:RightWheel/drive:MotorPort"/>
                </td>
              </tr>
              <tr>
                <th>Radius:</th>
                <td>
                  <xsl:value-of select="drive:RightWheel/drive:WheelRadius"/>
                </td>
              </tr>
              <tr>
                <th>Gear Ratio:</th>
                <td>
                  <xsl:value-of select="drive:RightWheel/drive:GearRatio"/>
                </td>
              </tr>
              <tr>
                <th>Current Power:</th>
                <td>
                  <input type="text" name="RightPower" size="20">
                    <xsl:attribute name="value">
                      <xsl:value-of select="drive:RightWheelPower"/>
                    </xsl:attribute>
                  </input>
                </td>
              </tr>
              <tr>
                <th>Reverse Polarity:</th>
                <td>
                  <xsl:value-of select="drive:RightWheel/drive:ReversePolarity"/>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <input id="Button2" type="reset" value="Reset" name="buttonReset" title="Reset Configuration"/>
      <input type="submit" value="Stop" name="AllStop" title="Stop"/>
      <input type="submit" value="Set Power" name="CustomPower" title="Set The Motor Power"/>
    </form>
    <form method="POST" action="" name="ConfigurationForm">
      <table width="100%">
        <tr>
          <th width="20%">Is Enabled:</th>
          <td width="80%">
            <xsl:value-of select="drive:IsEnabled"/>
          </td>
        </tr>
        <tr class="odd">
          <th>Distance Between Wheels:</th>
          <td>
            <xsl:value-of select="drive:DistanceBetweenWheels"/>
          </td>
        </tr>
        <tr>
          <th></th>
          <td>
            <xsl:choose>
              <xsl:when test='drive:IsEnabled = "true"'>
                <input type="submit" value="Disable Drive" name="DisableDrive" title="Disable Drive"/>
              </xsl:when>
              <xsl:otherwise>
                <input type="submit" value="Enable Drive" name="EnableDrive" title="Enable Drive"/>
              </xsl:otherwise>
            </xsl:choose>
          </td>
        </tr>
      </table>
    </form>
  </xsl:template>
</xsl:stylesheet>
